﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.SqlClient;
using System.Data;

namespace DAO
{
    public class ChiTietLaiSuatDA
    {
        public static ChiTietLaiSuat GetByID(int maID)
        {
            ChiTietLaiSuat loai = null;
            SqlConnection cn = DataProvider.Connect();
            SqlCommand cmd = new SqlCommand("Proc_ChiTietLaiSuat_GetById", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@maChiTietLS", maID));
            SqlDataReader dataReader = cmd.ExecuteReader();
            if (dataReader.Read())
            {
                loai = new ChiTietLaiSuat();
                loai.MaChiTietLS = Convert.ToInt32(dataReader["MaChiTietLS"]);
                loai.MaLoaiKHLS = Convert.ToInt32(dataReader["MaLoaiKHLS"]);
                loai.MaNgayVDLS = Convert.ToInt32(dataReader["MaNgayVDLS"]);
                loai.MucLS = Convert.ToSingle(dataReader["MucLS"]);
                loai.MaLoaiTien = Convert.ToInt32(dataReader["LoaiTien"]);
                loai.LastUpdate = Convert.ToDateTime(dataReader["LastUpdate"]);
            }
            cn.Close();
            return loai;
        }
    }
}
